package io.adrainty.bolee.framework.commons.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import io.adrainty.bolee.framework.commons.basic.IEnum;

import java.io.IOException;

/**
 * @author AdRainty
 * @version V1.0.0
 * @since 2025/8/10 下午10:53
 */
public class EnumSerializer extends JsonSerializer<IEnum> {

    @Override
    public void serialize(IEnum value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        if (value == null) {
            gen.writeNull();
            return;
        }
        gen.writeObject(value.getCode());
    }

}
